Skip to content

Improve integration project dependency management, conflict detection, and connector handling#2119

Open
chathuranga-jayanath-99 wants to merge 11 commits intowso2:release/mi-3.2.0from
chathuranga-jayanath-99:add-changes-for-connector-dep
Open

Improve integration project dependency management, conflict detection, and connector handling#2119
chathuranga-jayanath-99 wants to merge 11 commits intowso2:release/mi-3.2.0from
chathuranga-jayanath-99:add-changes-for-connector-dep

Conversation

@chathuranga-jayanath-99
Copy link
Copy Markdown
Contributor

Purpose

This PR introduces the following changes:

  • Updated the integration project dependency download flow:
    • Fetch connectors from integration project dependencies
    • Refetching now downloads all integration project dependencies from scratch.
    • Updating integration project dependencies now downloads only newly added dependencies and removes deleted ones.
  • The connector delete button is now shown only for connectors that belong to the current project.
  • Added error messaging when adding a connector causes conflicts with existing integration project dependencies.
  • Added conflict detection for resources and connectors during both dependency addition and initial project loading. If conflicts are detected, the conflicting dependencies are automatically removed from the project.

Related PRs

Previously, the Extracted dir is cleared at the beginning and the .zip files were removed after extraction.
Introduces a new RPC method that clears the currently downloaded
integration project dependencies and re-downloads the latest..
Connectors sourced from dependent integration projects do not display
a delete button, as they cannot be removed from the referencing project.
…ct dependency

Prevents adding a connector that already exists in a dependent
integration project and displays an appropriate error to the user.
Prevent adding the dependency if conflicts are detected. Identifies conflicting entries when adding integration project dependencies, show an error message, and removes existing conflicting entries from pom.xml if present.
Update the warning message for conflicting artifacts to prevent UI clutter by truncating overly long strings, thee full detailed error remains accessible in console logs
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99451563-e913-4fb8-93ae-df4a1102f3b3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ChinthakaJ98 ChinthakaJ98 requested a review from Copilot April 28, 2026 04:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts (1)

290-306: ⚠️ Potential issue | 🟡 Minor

Pick the warning from the dependency that actually failed.

This branch still uses params.newDependencies[0], so a batch update can show the wrong warning when the failed item is not the first one in the request. Use the matched failed dependency instead of the first input item.

🛠️ Suggested adjustment
-                        const newDep = params.newDependencies[0];
-                        const dependencyString = `${newDep.groupId}-${newDep.artifact}-${newDep.version}`;
+                        const failedDep = dependenciesToRemove[0];
+                        const dependencyString = failedDep
+                            ? `${failedDep.groupId}-${failedDep.artifact}-${failedDep.version}`
+                            : "";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts`
around lines 290 - 306, The code uses params.newDependencies[0] (newDep) which
can be the wrong item for batch updates; instead, find the specific dependency
object from params.newDependencies whose groupId-artifact-version matches the
dependency key you're checking against (the same string used with
connectorsNotDownloaded, connectorsFromIntegrationProjectDeps,
unavailableDependencies, missingDescriptorDependencies,
versioningMismatchDependencies), assign that matched dependency to newDep and
then build dependencyString from it before selecting the warning message.
🧹 Nitpick comments (2)
workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts (2)

854-864: Drop the extra save before formatting.

formatAndSavePomDocument() already applies formatting and saves the file, so the explicit document.save() here just adds an extra write cycle.

♻️ Suggested cleanup
         const document = await workspace.openTextDocument(pomPath);
-        await document.save();
         await formatAndSavePomDocument(pomPath);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts`
around lines 854 - 864, The extra explicit save is redundant because
formatAndSavePomDocument(pomPath) already formats and saves the file; remove the
document.save() call after opening the document. Locate the block that calls
workspace.applyEdit(edit), then workspace.openTextDocument(pomPath), and delete
the await document.save() line so the flow becomes applyEdit -> openTextDocument
-> formatAndSavePomDocument(pomPath), leaving the subsequent MACHINE_VIEW check
with getStateMachine(this.projectUri).context() and refreshUI(this.projectUri)
unchanged.

433-438: Consider surfacing the combined refetch + reload outcome.

This method returns only the raw refetch response, so callers cannot tell whether the follow-up loadCAppResources() step completed cleanly or hit a conflict/error path. A structured result would make the flow easier to reason about.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts`
around lines 433 - 438, The method refetchIntegrationProjectDependencies
currently returns only the raw refetch response (res) and hides the outcome of
the subsequent loadCAppResources(this.projectUri, langClient) call; change the
method to return a structured result (e.g., an object with refetchResult and
reloadResult or status fields) and capture errors from loadCAppResources to
populate reloadResult (success/failure and optional error message), so callers
can inspect both outcomes; update references to MILanguageClient.getInstance,
refetchIntegrationProjectDependencies, and loadCAppResources in this function to
return and propagate the new structured response instead of just res.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@workspaces/mi/mi-extension/src/visualizer/activate.ts`:
- Around line 571-574: The Range creation incorrectly subtracts 1 from
pomValue.range.start.{line,character} and pomValue.range.end.{line,character},
causing off-by-one shifts; update the Range(...) in activate.ts (the new Range
and Position calls) to use pomValue.range.* values directly (no "- 1") so they
remain in LSP/VS Code zero-based coordinates, and apply the same fix where
textEdit.range is constructed in rpc-manager (rpc-manager.ts) to remove the "-
1" adjustments.

In `@workspaces/mi/mi-visualizer/src/views/Overview/ProjectInformation/index.tsx`:
- Around line 208-210: The reloadDependencies handler fires an async RPC without
awaiting or handling failures; update the reloadDependencies function to await
rpcClient.getMiVisualizerRpcClient().refetchIntegrationProjectDependencies() and
wrap it in a try/catch, logging errors (or showing a user notification) on
failure and optionally returning or rethrowing as appropriate; reference the
reloadDependencies function and the refetchIntegrationProjectDependencies method
on rpcClient.getMiVisualizerRpcClient() when making the change.

---

Outside diff comments:
In `@workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts`:
- Around line 290-306: The code uses params.newDependencies[0] (newDep) which
can be the wrong item for batch updates; instead, find the specific dependency
object from params.newDependencies whose groupId-artifact-version matches the
dependency key you're checking against (the same string used with
connectorsNotDownloaded, connectorsFromIntegrationProjectDeps,
unavailableDependencies, missingDescriptorDependencies,
versioningMismatchDependencies), assign that matched dependency to newDep and
then build dependencyString from it before selecting the warning message.

---

Nitpick comments:
In `@workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts`:
- Around line 854-864: The extra explicit save is redundant because
formatAndSavePomDocument(pomPath) already formats and saves the file; remove the
document.save() call after opening the document. Locate the block that calls
workspace.applyEdit(edit), then workspace.openTextDocument(pomPath), and delete
the await document.save() line so the flow becomes applyEdit -> openTextDocument
-> formatAndSavePomDocument(pomPath), leaving the subsequent MACHINE_VIEW check
with getStateMachine(this.projectUri).context() and refreshUI(this.projectUri)
unchanged.
- Around line 433-438: The method refetchIntegrationProjectDependencies
currently returns only the raw refetch response (res) and hides the outcome of
the subsequent loadCAppResources(this.projectUri, langClient) call; change the
method to return a structured result (e.g., an object with refetchResult and
reloadResult or status fields) and capture errors from loadCAppResources to
populate reloadResult (success/failure and optional error message), so callers
can inspect both outcomes; update references to MILanguageClient.getInstance,
refetchIntegrationProjectDependencies, and loadCAppResources in this function to
return and propagate the new structured response instead of just res.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 325053bf-56fc-490a-966b-61bd8c649c3a

📥 Commits

Reviewing files that changed from the base of the PR and between a5babc1 and 8945ea2.

📒 Files selected for processing (12)
  • workspaces/mi/mi-core/src/rpc-types/mi-visualizer/index.ts
  • workspaces/mi/mi-core/src/rpc-types/mi-visualizer/rpc-type.ts
  • workspaces/mi/mi-diagram/src/components/sidePanel/commons/ButtonGroup.tsx
  • workspaces/mi/mi-diagram/src/components/sidePanel/mediators/List.tsx
  • workspaces/mi/mi-extension/src/lang-client/ExtendedLanguageClient.ts
  • workspaces/mi/mi-extension/src/lang-client/activator.ts
  • workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-handler.ts
  • workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts
  • workspaces/mi/mi-extension/src/util/fileOperations.ts
  • workspaces/mi/mi-extension/src/visualizer/activate.ts
  • workspaces/mi/mi-rpc-client/src/rpc-clients/mi-visualizer/rpc-client.ts
  • workspaces/mi/mi-visualizer/src/views/Overview/ProjectInformation/index.tsx

Comment thread workspaces/mi/mi-extension/src/visualizer/activate.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves integration project dependency management by adding a dedicated “refetch integration project dependencies” flow, expanding dependent resource loading to detect/remove conflicts, and tightening connector handling in the UI (e.g., only allowing deletion of connectors belonging to the current project).

Changes:

  • Introduces a new RPC method to refetch integration project dependencies and wires it through visualizer UI → RPC client → extension handlers → language client.
  • Centralizes dependent CApp resource loading (loadCAppResources) with conflict detection and automatic cleanup of conflicting dependencies in pom.xml.
  • Updates connector UI behavior so delete actions are only enabled for connectors identified as local to the current project.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
workspaces/mi/mi-visualizer/src/views/Overview/ProjectInformation/index.tsx Switches overview dependency reload to use the new refetch RPC method.
workspaces/mi/mi-rpc-client/src/rpc-clients/mi-visualizer/rpc-client.ts Adds RPC client method for refetchIntegrationProjectDependencies.
workspaces/mi/mi-extension/src/visualizer/activate.ts Adds loadCAppResources and conflict cleanup logic; adjusts dependency extraction behavior.
workspaces/mi/mi-extension/src/util/fileOperations.ts Adds shared formatAndSavePomDocument helper for formatting/saving pom.xml.
workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-manager.ts Adds manager method for refetch; routes dependent resource loading through loadCAppResources; refactors pom edit+format flow to shared helper.
workspaces/mi/mi-extension/src/rpc-managers/mi-visualizer/rpc-handler.ts Registers the new refetch RPC request handler.
workspaces/mi/mi-extension/src/lang-client/activator.ts Updates initial language-client startup flow to update connectors and load dependent resources via loadCAppResources.
workspaces/mi/mi-extension/src/lang-client/ExtendedLanguageClient.ts Adds refetchIntegrationProjectDependencies request + typed loadDependentCAppResources response model including conflict metadata.
workspaces/mi/mi-diagram/src/components/sidePanel/mediators/List.tsx Enables delete action only for connectors determined to be local to the current project.
workspaces/mi/mi-diagram/src/components/sidePanel/commons/ButtonGroup.tsx Makes delete icon conditional on onDelete being provided.
workspaces/mi/mi-core/src/rpc-types/mi-visualizer/rpc-type.ts Adds the new request type constant for refetch.
workspaces/mi/mi-core/src/rpc-types/mi-visualizer/index.ts Extends MIVisualizerAPI with the new refetch method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread workspaces/mi/mi-extension/src/visualizer/activate.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants